package com.example.e_comm.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 迪斯乔斯达
 * @version 0.1
 * @data 2025/10/14 09:25
 */
@Data
@TableName("roles")
@AllArgsConstructor
@NoArgsConstructor
public class Role {

    public Role(Long id, String name, String description, String roleKey) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.roleKey = roleKey;
        this.status = 1;
        this.deleted = 0;
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    private String description;

    @TableField(value = "role_key")
    private String roleKey;//角色标识
    private Integer status;
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime = LocalDateTime.now();
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime = LocalDateTime.now();

    @TableField(exist = false)
    private List<Permission> permissions;

    // 正确的 getter
    public String getRoleKey() {
        return roleKey;
    }
    // 正确的 setter
    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }
}
